package com.lulu.baselib.api;

import java.util.HashMap;

import okhttp3.FormBody;
import okhttp3.RequestBody;

/**
 * Author: XuChang
 * Date: 2019/10/26 10:16
 * Email: 123286473@qq.com
 * Description: 请求格式化
 * History:
 */
public class FormRequest {

    /**
     * 根据参数字段，获取该应用需要的请求body
     * @param hashMap
     * @return
     */
    public static RequestBody getFormRequest(HashMap<String,String> hashMap){
        FormBody.Builder builder = new FormBody.Builder();
        for (String s : hashMap.keySet()) {
            builder.addEncoded(s, hashMap.get(s));
        }
        FormBody build = builder.build();
        return build;
    }
}
